﻿using System;
using System.Linq.Expressions;
using System.Data.Objects.DataClasses;

namespace Relocation.Data
{
	public class EntityObjectExpend<T> : EntityObject
	{
		static public string GetPropName(Expression<Func<T, object>> expr)
		{
			switch (expr.Body.NodeType)
			{
				case ExpressionType.MemberAccess:
					return ((MemberExpression)expr.Body).Member.Name;
				case ExpressionType.Convert:
					return ((MemberExpression)((UnaryExpression)expr.Body).Operand).Member.Name;
				default:
					return null;
			}
		}
	}
}
